package com.wrupple.muba.util.client;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.wrupple.muba.util.client.api.transition.CurtainTransition;
import com.wrupple.muba.util.client.api.transition.PanelAnimator;
import com.wrupple.muba.util.client.api.transition.PanelTransition;
import com.wrupple.muba.util.client.api.transition.PanelTransition.Orientation;
import com.wrupple.muba.util.client.api.transition.SimplePanelAnimator;


public class SlidingDialog {			

	public static PanelAnimator slideFromTop(LayoutPanel wrapper, Widget child, Widget brother, double heightInPixels) {
		PanelAnimator animator = new SimplePanelAnimator();
		CurtainTransition transition = new CurtainTransition(PanelTransition.Orientation.TOP, child, brother,wrapper);
		transition.setFinalHeight(heightInPixels, Unit.PX);
		animator.addTransition(transition);
		animator.setLayoutPanel(wrapper);
		return animator;
	}
	
	public static PanelAnimator slideFromRight(LayoutPanel wrapper, Widget child, Widget brother, int widthInPCT) {
		PanelAnimator animator = new SimplePanelAnimator();
		CurtainTransition transition = new CurtainTransition(PanelTransition.Orientation.RIGHT, child, brother,wrapper);
		transition.setFinalWidth(widthInPCT, Unit.PCT);
		animator.addTransition(transition);
		animator.setLayoutPanel(wrapper);
		return animator;
	}
	

	public static CurtainTransition createTransition(Orientation from, Widget child, Widget brother, LayoutPanel parent, double heightOrWidthInPixels){
		return new CurtainTransition(from,child,brother,parent,heightOrWidthInPixels,Unit.PX);
	}

	public static PanelAnimator slideFromLeft(LayoutPanel wrapper, Widget child, Widget brother, int widthInPCT) {
		PanelAnimator animator = new SimplePanelAnimator();
		CurtainTransition transition = new CurtainTransition(PanelTransition.Orientation.LEFT, child, brother,wrapper);
		transition.setFinalWidth(widthInPCT, Unit.PCT);
		animator.addTransition(transition);
		animator.setLayoutPanel(wrapper);
		return animator;
	}

}